<template>
  <div>
    <el-card style="margin: 10px;">
      <el-row>
        发货列表
      </el-row>
      <el-divider></el-divider>

      <template>
        <el-table :data="tableData" style="width: 100%" border>
          <el-table-column prop="orderSn" label="订单号" width="180" align="center">
          </el-table-column>
          <el-table-column prop="receiverName" label="收件人" width="80" align="center">
          </el-table-column>
          <el-table-column prop="receiverPhone" label="手机号码" align="center">
          </el-table-column>
          <el-table-column prop="receiverPostCode" label="邮政地址" align="center">
          </el-table-column>
          <el-table-column prop="" label="配送地址" align="center">
            <template #default="{row,$index}">
              {{ row.receiverProvince + row.receiverCity + row.receiverRegion + row.receiverDetailAddress }}
            </template>
          </el-table-column>
          <el-table-column prop="" label="配送方式" align="center">
            <template #default="{row,$index}">
              <el-select v-model="row.deliveryCompany">
                <el-option label="圆通快递" value="圆通快递"></el-option>
                <el-option label="顺丰快递" value="顺丰快递"></el-option>
                <el-option label="中通快递" value="中通快递"></el-option>
                <el-option label="韵达快递" value="韵达快递"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column prop="logistics" label="物流单号" align="center">
            <template #default="{row,$index}">
              <el-input v-model="row.deliverySn" placeholder="请输入物流单号"></el-input>
            </template>
          </el-table-column>

          <el-table-column prop="配送方式" label="操作" align="center">
            <template #default="{row,$index}">
              <el-button type="primary" size="small" @click="submit(row)">确定</el-button>
              <el-button size="small" @click="$router.go(-1)">取消</el-button>
            </template>
          </el-table-column>
        </el-table>
      </template>

    </el-card>
  </div>
</template>

<script>
import {listOrder, getOrder, delOrder, addOrder, updateOrder} from "@/api/order/order";

export default {
  name: 'WorkspaceJsonDeliver',

  data() {
    return {
      tableData: [],
      logistics: ''
    };
  },
  mounted() {
    this.tableData = []
    this.tableData.push(JSON.parse(this.$route.query.orderList))
  },

  methods: {
    submit(row) {
      row.status = 2
      if (row.deliverySn == '' || row.deliverySn ==null) {
        this.$message.error("请填写物流单号！")
      } else if (row.deliveryCompany == '' || row.deliveryCompany ==null) {
        this.$message.error("请填写配送方式！")
      }
      updateOrder(row).then(res => {
        if (res.code == 200) {
          this.$message.success("发货成功！")
          this.$router.go(-1)
        }
      })
    }
  },
};
</script>

<style lang="scss" scoped>

</style>
